
package net.phoenix.repository.query.qom2;

import javax.jcr.query.qom.And;
import javax.jcr.query.qom.Constraint;



/**
 * <code>AndImpl</code>...
 */
public class AndImpl extends ConstraintImpl implements And {

    /**
     * The first constraint.
     */
    private final ConstraintImpl constraint1;

    /**
     * The second constraint.
     */
    private final ConstraintImpl constraint2;

    AndImpl(NamePathResolver resolver, ConstraintImpl c1, ConstraintImpl c2) {
        super(resolver);
        this.constraint1 = c1;
        this.constraint2 = c2;
    }

    /**
     * Gets the first constraint.
     *
     * @return the constraint; non-null
     */
    public Constraint getConstraint1() {
        return constraint1;
    }

    /**
     * Gets the second constraint.
     *
     * @return the constraint; non-null
     */
    public Constraint getConstraint2() {
        return constraint2;
    }

    //------------------------< AbstractQOMNode >-------------------------------

    /**
     * Accepts a <code>visitor</code> and calls the appropriate visit method
     * depending on the type of this QOM node.
     *
     * @param visitor the visitor.
     */
    public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
        return visitor.visit(this, data);
    }

    //------------------------< Object >----------------------------------------

    public String toString() {
        return protect(constraint1) + " AND " + protect(constraint2);
    }

}
